const express = require('express');
// const fetch = require('node-fetch');
var router = express.Router();

/* GET home page. */
router.get('/', function (req, res, next) {
  res.render('index', { title: 'Express' });
});
// routes/index.js
(async () => {
  const fetch = (await import('node-fetch')).default;

  // 你的其他代码逻辑
  router.get('/get-location', async (req, res) => {
    const ipResponse = await fetch('https://ipinfo.io/json?token=YOUR_TOKEN');
    const data = await ipResponse.json();
    res.json(data);
  });
})();



module.exports = router;
